#include "CGame.h"

#ifndef _SOUND_H_
#define _SOUND_H_

/////////////
// LINKING //
/////////////
#pragma comment(lib, "dsound.lib")
#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "winmm.lib")
 
 
//////////////
// INCLUDES //
//////////////
#include <windows.h>
#include <mmsystem.h>
#include <dsound.h>
#include <stdio.h>



///////////////////////////////////////////////////////////////////////////////
// Class name: Sound
///////////////////////////////////////////////////////////////////////////////
class Sound
{
private:
	struct WaveHeaderType
	{
		char chunkId[4];
		unsigned long chunkSize;
		char format[4];
		char subChunkId[4];
		unsigned long subChunkSize;
		unsigned short audioFormat;
		unsigned short numChannels;
		unsigned long sampleRate;
		unsigned long bytesPerSecond;
		unsigned short blockAlign;
		unsigned short bitsPerSample;
		char dataChunkId[4];
		unsigned long dataSize;
	};

	IDirectSoundBuffer8* _secondaryBuffer;
	char* _fileName;
	bool _mute;

public:
	Sound();
	Sound(char* filename);
	Sound(const Sound&);
	~Sound();

	bool LoadWaveFile(char* filename, IDirectSoundBuffer8** secondaryBuffer);
	bool Play(bool Loop);
	void Stop();
	char* GetFileName(){return _fileName;}
	void SetMute(bool value);
	void Release();
};

#endif